find_package(Git QUIET)
if(GIT_FOUND)
    execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=format:%H
        OUTPUT_VARIABLE GIT_HASH
        OUTPUT_STRIP_TRAILING_WHITESPACE
        ERROR_QUIET)
    execute_process(COMMAND ${GIT_EXECUTABLE} symbolic-ref --quiet --short HEAD
        OUTPUT_VARIABLE GIT_BRANCH
        OUTPUT_STRIP_TRAILING_WHITESPACE
        ERROR_QUIET)
    execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=format:%ct
        OUTPUT_VARIABLE COMMIT_TIME_TEMP
        OUTPUT_STRIP_TRAILING_WHITESPACE
        ERROR_QUIET)
    execute_process(COMMAND date -d@${COMMIT_TIME_TEMP} +"%Y-%m-%d %H:%M:%S"
        OUTPUT_VARIABLE COMMIT_TIME
        OUTPUT_STRIP_TRAILING_WHITESPACE
        ERROR_QUIET)
    execute_process(COMMAND ${GIT_EXECUTABLE} remote -v | grep fetch | awk '{print $$2}' | awk -F '@' '{print $$2}' | awk -F '/' '{print $$2}'
        OUTPUT_VARIABLE GIT_REPOSITORY
        OUTPUT_STRIP_TRAILING_WHITESPACE
        ERROR_QUIET)
endif()

string(TIMESTAMP COMPILE_TIME "%Y-%m-%d %H:%M:%S")
set(BUILD_TIME ${COMPILE_TIME})

configure_file(
    ${CMAKE_SOURCE_DIR}/config/version.h.in
    ${CMAKE_SOURCE_DIR}/config/version.h
    @ONLY)

